/**
 * @author Chris Lewis Dec 29, 2007 <chris@thegodcode.net>
 * @version $Id: clicksubmit.js 81 2007-12-29 19:42:13Z burningodzilla $
 */

/*
 * ClickSubmit attaches a handler to the specified element. This handler
 * responds to the 'onclick' event, and when triggered, submits the containing
 * form. Note that it expects (requries) the element to be a descendant
 * of a form, and the containing form will be the target for submission.
 */
var ClickSubmit = Class.create();
ClickSubmit.prototype = {
	initialize: function(e) {
		$(e).ancestors().each(
			function(ae) {
				if(ae.tagName == 'FORM') {
					Event.observe(e, 'click', function() { ae.submit(); });
				}
			}
		);
	}
}